home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / e_to_l / itgraph / msvc15 / itgdmdoc.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-15  |  3.4 KB  |  138 lines

  1. // itgdmdoc.cpp : implementation of the CItgDemoDoc class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "itgdemo.h"
  6.  
  7. #include "itgdmdoc.h"
  8. #include "itgdmvw.h"
  9.  
  10. #include "itgdefs.h"
  11.  
  12. #ifdef _DEBUG
  13. #undef THIS_FILE
  14. static char BASED_CODE THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CItgDemoDoc
  19.  
  20. IMPLEMENT_DYNCREATE(CItgDemoDoc, CDocument)
  21.  
  22. BEGIN_MESSAGE_MAP(CItgDemoDoc, CDocument)
  23.     //{{AFX_MSG_MAP(CItgDemoDoc)
  24.     ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
  25.     ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
  26.     ON_COMMAND(ID_FILE_NEW, OnFileNew)
  27.     ON_COMMAND(ID_FILE_SAVE, OnFileSave)
  28.     //}}AFX_MSG_MAP
  29. END_MESSAGE_MAP()
  30.  
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CItgDemoDoc construction/destruction
  33.  
  34. CItgDemoDoc::CItgDemoDoc()
  35. {
  36. }
  37.  
  38. CItgDemoDoc::~CItgDemoDoc()
  39. {
  40. }
  41.  
  42. BOOL CItgDemoDoc::OnNewDocument()
  43. {
  44.     if (!CDocument::OnNewDocument())
  45.         return FALSE;
  46.  
  47.     // TODO: add reinitialization code here
  48.     // (SDI documents will reuse this document)
  49.  
  50.     return TRUE;
  51. }
  52.  
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CItgDemoDoc serialization
  55.  
  56. void CItgDemoDoc::Serialize(CArchive& ar)
  57. {
  58.     if (ar.IsStoring())
  59.     {
  60.         // TODO: add storing code here
  61.     }
  62.     else
  63.     {
  64.         // TODO: add loading code here
  65.     }
  66. }
  67.  
  68. /////////////////////////////////////////////////////////////////////////////
  69. // CItgDemoDoc diagnostics
  70.  
  71. #ifdef _DEBUG
  72. void CItgDemoDoc::AssertValid() const
  73. {
  74.     CDocument::AssertValid();
  75. }
  76.  
  77. void CItgDemoDoc::Dump(CDumpContext& dc) const
  78. {
  79.     CDocument::Dump(dc);
  80. }
  81. #endif //_DEBUG
  82.  
  83. /////////////////////////////////////////////////////////////////////////////
  84. // CItgDemoDoc commands
  85.  
  86. void CItgDemoDoc::OnFileSaveAs()
  87. {
  88.     POSITION pos = GetFirstViewPosition();
  89.     CItgDemoView* pFirstView = (CItgDemoView *)GetNextView( pos );
  90.     CFileDialog dlgSaveAs(FALSE, "itg", "*.itg", OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY,
  91.         "ITGraph Files (*.itg) | *.itg | All Files (*.*) | *.* ||", pFirstView);
  92.     if(dlgSaveAs.DoModal() == IDOK) {
  93.         CVBControl *pITG = pFirstView->m_ITGraph;
  94.         SetPathName(dlgSaveAs.GetPathName());
  95.         pITG->SetStrProperty("SaveAs", GetPathName());
  96.     }
  97. }
  98.  
  99. void CItgDemoDoc::OnFileOpen()
  100. {
  101.     POSITION pos = GetFirstViewPosition();
  102.     CItgDemoView* pFirstView = (CItgDemoView *)GetNextView( pos );
  103.     if(pFirstView->AskToSave()) {
  104.         CFileDialog dlgOpen(TRUE, "itg", "*.itg", OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY,
  105.             "ITGraph Files (*.itg) | *.itg | All Files (*.*) | *.* ||", pFirstView);
  106.         dlgOpen.m_ofn.nFilterIndex = 1;
  107.         if(dlgOpen.DoModal() == IDOK) {
  108.             CVBControl *pITG = pFirstView->m_ITGraph;
  109.             SetPathName(dlgOpen.GetPathName());
  110.             pITG->SetStrProperty("LoadFrom", GetPathName());
  111.             pITG->SetNumProperty("IsDirty", FALSE);
  112.         }
  113.     }
  114. }
  115.  
  116. void CItgDemoDoc::OnFileNew()
  117. {    
  118.     POSITION pos = GetFirstViewPosition();
  119.     CItgDemoView* pFirstView = (CItgDemoView *)GetNextView( pos );
  120.     if(pFirstView->AskToSave()) {
  121.         CVBControl *pITG = pFirstView->m_ITGraph;
  122.         SetTitle("");
  123.         pITG->SendMessage(VBM_METHOD, METH_CLEAR, 0L);
  124.     }
  125. }
  126.  
  127. void CItgDemoDoc::OnFileSave()
  128. {
  129.     POSITION pos = GetFirstViewPosition();
  130.     CItgDemoView* pFirstView = (CItgDemoView *)GetNextView( pos );
  131.     if((GetPathName() == "") || (GetTitle() == ""))
  132.         OnFileSaveAs();
  133.     else {
  134.         CVBControl *pITG = pFirstView->m_ITGraph;
  135.         pITG->SetStrProperty("SaveAs", GetPathName());
  136.     }        
  137. }
  138.